<?php
include_once './vendor/autoload.php';

function dd($var){
//    echo __FILE__;
    echo '<br><pre>';
    print_r($var);
    echo '</pre>';
    die;
}
//新加方法 暂时用不到
function get_file_mimetype($filePath){
    $finfo    = finfo_open(FILEINFO_MIME);
    $mimetype = finfo_file($finfo, $filePath);
    finfo_close($finfo);
    return $mimetype;
}
// hotcast-test001
// 测试图片 test_img 1.4mb左右
// 测试视频 test_mp4 110mb左右
// 测试mp4  test_video
if(!empty($_POST)){
    //分片上传
    $url = \Wcs\WcsFile::UploadMkblk('hotcast-test001',$_POST['filename'],$_POST['filepath']);
    dd($url);
}
$url = './wait_to_upload/';
$arr = scandir($url);
var_dump($arr);
foreach($arr as $k=>$v){
    if($v == '.' || $v == '..' || $v == '.DS_Store'){
        unset($arr[$k]);
    }
}
dd($arr);

//$fp = file_get_contents('./bigvideo.mp4.rcd');
//$fp = fopen('./bigvideo.mp4.rcd', 'r');
//fseek($fp, -1024,SEEK_END);

// read some data
//$data = fgets($fp, 4096);
//var_dump($data);

//分片上传
//$url = \Wcs\WcsFile::UploadMkblk('hotcast-test001','bigvideo.mp4','bigvideo.mp4');
//获取文件公共下载地址
//$url = \Wcs\WcsFile::getPublicDownloadUrl('hotcast-test001','test_mp4');
//普通上传
//$url = \Wcs\WcsFile::getPublicUploadUrl('hotcast-test001','test_img2.png','1.png');
//获取文件信息
//$url = \Wcs\WcsFile::getFileInfo('hotcast-test001','test_video1.mp4');
//获取图片信息
//$url = \Wcs\WcsFile::getImageInfo('hotcast-test001','test_img2');
//dd($url);
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<form action="" method="post">
    文件名:<input type="text" name="filename" id="" value="test_video1.mp4"> <br>
    文件路径: <input type="text" name="filepath" id="" value="test1.mp4"> <br>
    <input type="submit" value="提交">
</form>

</body>
</html>
